package com.jeff.grailsstudy

class Book {
    String title
    double price
    String publisher
    Date released
    
    static belongsTo = [author: Author]
    
    static constraints = {
        title size: 3..16, blank: false, unique: true
        price min: new Double(1)
        publisher(shared: "myShared") //myShared defined in Config.groovy
    }
    
    static namedQueries = {
        beginWithTitleMyBook {
            like 'title', "MyBook%"
        }
    }
    
    def String toString() {
        return "${this.class}: $title - ${price}"
    }
}
